export default {
  data() {
    return {
      form: {
        appealName: "",
        contacts: "",
        contactsTel: "",
        financingName: "",
        financingIntroduce: "",
        financingType: "",
        financingTurn: "",
        financeStatus: "",
        provinceCode: "",
        cityCode: "",
        countyCode: "",
        detailedAddress: "",
        describeType: "",
        projectDescribe: "",
        projectDetails: "",
        startTimeStr: "",
        endTimeStr: "",
        financingMoney: "",
        financingPurpose: "",
        guaranteeType: "",
        financingExpect: "",
        officialWebsite: "",
        companyTag: [],
        financingStatus: 0, // 保存0，申请1
        fDate: null, // 时间验证用的字段
      },
      rules: {
        appealName: [
          { required: true, message: '请输入诉求名称', trigger: 'blur' }
        ],
        contacts: [
          { required: true, message: '请输入联系人', trigger: 'blur' }
        ],
        contactsTel: [
          { 
            required: true, 
            trigger: 'blur',
            validator: (rule, value, callback) => {
              if (!this.regCheck('empty', value)) {
                callback(new Error('请输入联系电话'));
              } else if (this.regCheck('phone', value)) {
                callback(new Error('请输入正确的联系电话'));
              } else {
                callback()
              }
            }, 
          }
        ],
        financingName: [
          { required: true, message: '请输入融资名称', trigger: 'blur' }
        ],
        financingType: [
          { required: true, message: '请选择融资类型', trigger: 'blur' }
        ],
        fDate: [
          { required: true, message: '请选择融资期限', trigger: 'blur' }
        ],
        financingMoney: [
          {
            required: true,
            trigger: 'blur',
            validator: (rule, value, callback) => {
              if (!this.regCheck('empty', value)) {
                callback(new Error('请输入融资金额'));
              } else if (this.regCheck('number', value)) {
                callback(new Error('请输入数字'));
              } else {
                callback()
              }
            },
          }
        ],
        financingIntroduce: [
          { required: true, message: '请输入简介', trigger: 'blur' }
        ],
        financingPurpose: [
          { required: true, message: '请输入资金用途', trigger: 'blur' }
        ],
        financingTurn: [
          { required: true, message: '请选择融资轮次', trigger: 'blur' }
        ],
        guaranteeType: [
          { required: true, message: '请输入担保方式', trigger: 'blur' }
        ],
        financeStatus: [
          { required: true, message: '请选择财务状况', trigger: 'blur' }
        ],
        financingExpect: [
          { required: true, message: '请输入融资期望', trigger: 'blur' }
        ],
        companyTag: [
          {
            required: true,
            type: "array",
            trigger: ["blur", "change"],
            validator: (rule, value, callback) => {
              let msg = this.regCheck('tag', value)
              if(msg) {
                callback(msg)
              } else {
                callback()
              }
            },
          },
        ],
      },
    }
  }
}
